import { useState } from "react";
function MyTime() {
  const [time, setTime] = useState(new Date());
  const year = time.getFullYear();
  const month = time.getMonth() + 1;
  const date = time.getDate();
  const hours = time.getHours();
  const minutes = time.getMinutes();
  const seconds = time.getSeconds();
  setInterval(() => {
    setTime(new Date());
  }, 1000);
  return (
    <div>
      <p>
        {year}年{month}月{date}日 {hours}:{minutes}:{seconds}
      </p>
    </div>
  );
}

export default MyTime;
